﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CarolLib;

namespace MiniCMS
{
    public partial class frmLogin : Form
    {
        public frmLogin()
        {
            InitializeComponent();
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (this.tbAccount.Text.Trim() == string.Empty || this.tbPwd.Text.Trim() == string.Empty)
            {
                MessageBox.Show("请输入用户名和密码", "输入用户名密码", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (AuthUserContext.Instance.Login(this.tbAccount.Text.Trim(), AuthUserContext.Encrypt(this.tbPwd.Text.Trim())))
            {
                this.Hide();
                frmMain main = new frmMain();
                main.Show();
                Log.Info("登录系统");
            }
            else
            {
                MessageBox.Show("用户名或密码错误！");
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Hide();
            frmMain main = new frmMain();
            main.Show();
        }
    }
}
